<?php
ob_start();
session_start();
$id=$_SESSION['id'];
?>

  
<div class="spacer"></div>
<?php $ris = GetServiceOn($id); ?>
<div class="apri"><label class="green">Add social Network</label></div>

<br />
   

<?php
 
       
       function GetServiceOn($idutente){

                 try{
                     include_once('restconnection.php');
                     
                     if(isset($client)){

                       
                        //retrive base url 
                        $url = $_SESSION['basic_url'];
                        //add service url
                        $service_url="/GetServiceOn?";
                        //params url
                        $params = array('id'=>$idutente);
                        //params connection
                        $ctx = stream_context_create(array('http' => array('timeout' => 1))); 
                        //send GET request
                        $output = @file_get_contents($url.$service_url."id=".$params['id'],0,$ctx);
                        //parse JSON output
                        $data = json_decode($output);
                        $webResult = $data->GetServiceOnResult;


                        return $webResult;
                     
                     }

                  }catch(Exception $e){

                     echo"Error";

                  }
       }
  
   //prendi dati da inserire nella home timeline
   
   
   $socialnetworks=$ris;
   //print_r($socialnetworks[1]);
   
   for($i=0;$i<count($socialnetworks);$i++){
        if($socialnetworks[$i]!=""){ 
            $socialactive[$i]=1;
        }else{    
        
            $socialactive[$i]=0;
        }
            
   }
  // print_r($socialactive);
   ?>
    <script language="JavaScript">
      
        
        var svector=new Array(); 
        <?php
        for($k=0;$k<count($socialactive);$k++){
        ?>	
        
            svector[<?php echo$k; ?>]="<?php echo$socialactive[$k]; ?>";
       
        <?php 
        }
        ?>
            setactive(svector);
        
        
    	
    </script> 
    
   <?php 
             
       $ris=0;

     if($ris == 0 ){
       
         
?>
    

   
    <div id="social" class=""> 

        <div id="content-logos">
        
            <div class="box-logos">
                <div   class="facebook img_social " id="FBimg" alt="Facebook" title="link Facebook" onclick=" popup('esa/Service/Facebook/facebook.php');">   

                    <div id="FBcheck" class="unchecked"></div>
                
                </div>
                <div class="google img_social " id="GPimg"  alt="Google+" title="link Google+"  onclick=" popup('esa/Service/Google/google.php');"> 
                   
                    <div id="GPcheck" class="unchecked"></div>
                </div>
                
                <div class="clear"></div>
            </div>
        
            <div class="box-logos">
                <div class="twitter img_social "  id="TWimg" alt="Twitter" title="link Twitter" onclick=" popup('esa/Service/Twitter/twitter.php');">   
 
                    <div id="TWcheck" class="unchecked"></div>
                </div>
                <div class="pinterest img_social " id="PIimg" alt="Pinterest" title="link Pinterest"  onclick=" popup('esa/Service/Pinterest/pinterest.php');"> 
                    
                    <div id="PIcheck" class="unchecked"></div>
                </div>
                
                <div class="clear"></div>
            </div>
            
            <div class="box-logos">
                <div class="linkedin img_social " id="LIimg" alt="Linkedin" title="link Linkedin" onclick=" popup('esa/Service/Linkedin/linkedin.php');" >   
                         
                    <div id="LIcheck" class="unchecked"></div>
                </div>
                <div class="foursqare img_social " id="FSimg" alt="Foursquare" title="link Foursquare"  onclick=" popup('esa/Service/Foursquare/fourquare.php');"> 
                                      
                    <div id="FScheck" class="unchecked"></div>
                </div>
                
                <div class="clear"></div>
            </div>
           
        </div>

      </div> 
    
    
<?php } ?>



 
